package cn.thoughtworks.school.usercenter.repositories;

import cn.thoughtworks.school.usercenter.entities.UserDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


public interface UserDetailRepository extends JpaRepository<UserDetail, Long> {
    List<UserDetail> getAllByUserIdIn(List<Long> ids);

    @Transactional
    @Modifying
    @Query(value = "update userDetail set currentOrganizationId=:organizationId where userId = :userId", nativeQuery = true)
    void updateCurrentOrganizationId(@Param("userId") Long userId,@Param("organizationId") Long organizationId);
}
